USE [Musicman]
GO
/****** Object:  StoredProcedure [dbo].[DeleteSearchFile]    Script Date: 12/02/2008 22:57:50 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
ALTER PROCEDURE [dbo].[DeleteSearchFile]
	@SearchFileID bigint
AS
BEGIN
BEGIN TRANSACTION;
BEGIN TRY	
		
	DELETE FROM  MUSICMAN.DBO.USERDOWNLOADS WHERE SearchFielID = @SearchFileID
	DELETE FROM  MUSICMAN.DBO.FILESSTATS WHERE SearchFileID = @SearchFileID
	DELETE FROM  MUSICMAN.DBO.SEARCHFILE WHERE SearchFileID = @SearchFileID

COMMIT TRANSACTION;
END TRY
BEGIN CATCH
	ROLLBACK TRANSACTION;

    DECLARE @ErrorMessage NVARCHAR(4000);
    DECLARE @ErrorSeverity INT;
    DECLARE @ErrorState INT;

    SELECT @ErrorMessage = ERROR_MESSAGE();
    SELECT @ErrorSeverity = ERROR_SEVERITY();
    SELECT @ErrorState = ERROR_STATE();
	RAISERROR (@ErrorMessage, -- Message text.
                   @ErrorSeverity, -- Severity.
                   @ErrorState -- State.
                   );
END CATCH


END
 